<template>
  <div class="app-container" style="margin-top: -20px;">

  <el-row :gutter="10" class="mb8">
    <right-toolbar :search="search" @queryTable="getList" ></right-toolbar>
  </el-row>

    <el-table v-loading="loading" :data="payLogList">

      <el-table-column label="日志类型" align="center" prop="logType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.pay_log_type" :value="scope.row.logType" />
        </template>
      </el-table-column>
      <el-table-column label="变更类型" align="center" prop="symbol">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.pay_balance_type" :value="scope.row.symbol" />
        </template>
      </el-table-column>
      <el-table-column label="余额类型" align="center" prop="balanceType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.balance_type" :value="scope.row.balanceType" />
        </template>
      </el-table-column>
      <el-table-column label="变更数量" align="center" prop="changeNum" >
        <template slot-scope="scope">
            <span v-if="scope.row.symbol=='+'" style="color: #13ce66;">{{scope.row.symbol+scope.row.changeNum}}</span>
            <span v-if="scope.row.symbol=='-'" style="color: red;">{{scope.row.symbol+scope.row.changeNum}}</span>
        </template>
      </el-table-column>
      <el-table-column label="变更前" align="center" prop="changeNum" >
        <template slot-scope="scope">
          <span v-if="scope.row.balanceType==1 && scope.row.walletSnapBefore ">{{JSON.parse(scope.row.walletSnapBefore).goldBalance}}</span>
          <span v-if="scope.row.balanceType==2 && scope.row.walletSnapBefore ">{{JSON.parse(scope.row.walletSnapBefore).diamondBalance}}</span>
          <span v-if="scope.row.symbol=='+'" style="color: #13ce66;">{{scope.row.symbol+scope.row.changeNum}}</span>
            <span v-if="scope.row.symbol=='-'" style="color: red;">{{scope.row.symbol+scope.row.changeNum}}</span>
        </template>
      </el-table-column>

      <el-table-column label="变更后" align="center" prop="changeNum" >
        <template slot-scope="scope">
          <span v-if="scope.row.balanceType==1 && scope.row.walletSnapAfter">{{JSON.parse(scope.row.walletSnapAfter).goldBalance}}</span>
          <span v-if="scope.row.balanceType==2 && scope.row.walletSnapAfter">{{JSON.parse(scope.row.walletSnapAfter).diamondBalance}}</span>

        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="创建日期" align="center" prop="logDate" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
    </el-table>

    <pagination :pageSizes="[5,10,15,20]" v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />


  </div>
</template>

<script>
  import {
    listPayLog,
  } from "@/api/service/pay/payLog";

  export default {
    name: "PayLog",
    dicts: ['pay_log_type', 'balance_type', 'pay_balance_type'],
    props: {
      userId: {
        type: String,
        default: '-1'
      },
      logType: {
        type: Array,
        default: [210]
      }
    },
    data() {
      return {
        search:false,
        // 按钮loading
        buttonLoading: false,
        // 遮罩层
        loading: true,

        // 总条数
        total: 0,
        // 关注-粉丝表格数据
        payLogList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 5,
          userId: this.userId,
          logType:this.logType
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {}
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询关注-粉丝列表 */
      getList() {
        this.loading = true;
        listPayLog(this.queryParams).then(response => {
          this.payLogList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },




    }
  };
</script>
